package com.example.mapper;

import com.example.entity.OrganizationBranch;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 操作organization_branch相关数据接口
*/
public interface OrganizationBranchMapper {

    /**
      * 新增
    */
    int insert(OrganizationBranch organizationBranch);

    /**
      * 删除
    */
    int deleteById(Integer id);

    /**
      * 修改
    */
    int updateById(OrganizationBranch organizationBranch);

    /**
      * 根据ID查询
    */
    OrganizationBranch selectById(Long id);

    /**
      * 查询所有
    */
    List<OrganizationBranch> selectAll(OrganizationBranch organizationBranch);

    @Select("select * from organization_branch where parent_id = #{id}")
    List<OrganizationBranch> selectByParentId(Integer id);

    // 根据多个父ID查询子支部
    List<OrganizationBranch> selectByParentIds(@Param("parentIds") List<Integer> parentIds);

    // 根据多个ID查询支部
    List<OrganizationBranch> selectByIds(@Param("ids") List<Integer> ids);

    // 批量删除
    void deleteBatchByIds(@Param("ids") List<Integer> ids);


    @Select("select id from organization_branch where leader_id = #{leaderId}")
    List<Long> selectByLeaderId(Long leaderId);

    List<OrganizationBranch> selectByLeaderIdAndOrgType(Long leaderId, Integer orgType);
}